//
//  THJContactInfoView.m
//  THJXHW
//
//  Created by 河南德艺 on 2018/8/15.
//  Copyright © 2018年 河南德艺. All rights reserved.
//

#import "THJContactInfoView.h"

@implementation THJContactInfoView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)init{
    
    self = [super init];
    self = [[[NSBundle mainBundle] loadNibNamed:@"THJContactInfoView" owner:self options:nil] lastObject];
    return self;
}
+(THJContactInfoView*)instancView{
    
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:@"THJContactInfoView" owner:nil options:nil];
    return [nibView objectAtIndex:0];
}
- (IBAction)close:(id)sender {
    
    if(!self.nameTf.text.length){
        [self HUDShowMsg:@"请填写姓名" AfterDelayDimiss:1];
        return;
    }else if (!self.phoneTf.text.length){
        [self HUDShowMsg:@"请填写电话" AfterDelayDimiss:1];
        
        return;
    }else if(!self.addressTf.text.length){
        [self HUDShowMsg:@"请填写地址" AfterDelayDimiss:1];
        return;
    }
    [self.delegate name:self.nameTf.text phone:self.phoneTf.text address:self.addressTf.text];
    [self removeFromSuperview];
}
-(void)HUDShowMsg:(NSString*)msg AfterDelayDimiss:(double)second{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = msg;
    //hud.label.backgroundColor = COLOR(0, 0, 0, 0.7);
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:second];
}
//-(void)getData{
//
//    NSString * mobile = [RSA encryptString:[THJTools getMobile] publicKey:RSA_PubKey];
//    NSLog(@"mobile-%@",mobile);
//    [THJNetWork postNetDataFromUrl:@"http://p.thjb.net/thjblink/appdata.php?action=shipping_address" parameters:@{@"type":@"ios",@"mobile":mobile} callback:^(NSDictionary *  receiveData, NSError *error) {
//        NSLog(@"位置信息--%@",receiveData);
//        if([receiveData[@"status"] isEqual:@"success"]){
//            NSLog(@"HJHJH-%@-%@-%@",self.nameTf.text,self.phoneTf.text,self.addressTf.text);
//            self.nameTf.text = [RSA decryptString:receiveData[@"data"][@"name"] publicKey:RSA_PubKey];
//            self.phoneTf.text = [RSA decryptString:receiveData[@"data"][@"mobile"] publicKey:RSA_PubKey];
//            self.addressTf.text = [RSA decryptString:receiveData[@"data"][@"address"] publicKey:RSA_PubKey];
////            NSLog(@"JHKJH-%@-%@-%@",[RSA decryptString:receiveData[@"data"][@"name"] publicKey:RSA_PubKey],[RSA decryptString:receiveData[@"data"][@"mobile"] publicKey:RSA_PubKey],[RSA decryptString:receiveData[@"data"][@"address"] publicKey:RSA_PubKey]);
//            NSLog(@"JKJKJK-%@-%@-%@",self.nameTf.text,self.phoneTf.text,self.addressTf.text);
//        }else{
//            [self HUDShowMsg:@"获取信息失败" AfterDelayDimiss:1];
//        }
//    }];
//}
@end
